package com.starsea.book.ui.newpage.weidget.banner.transformer

import android.view.View
import androidx.core.view.ViewCompat

/**
 * 描述:
 */
class AlphaPageTransformer : BannerPageTransformer {
  private var mMinScale = 0.4f

  constructor()
  constructor(minScale: Float) {
    setMinScale(minScale)
  }

  override fun handleInvisiblePage(view: View, position: Float) {
    ViewCompat.setAlpha(view, 0f)
  }

  override fun handleLeftPage(view: View, position: Float) {
    ViewCompat.setAlpha(view, mMinScale + (1 - mMinScale) * (1 + position))
  }

  override fun handleRightPage(view: View, position: Float) {
    ViewCompat.setAlpha(view, mMinScale + (1 - mMinScale) * (1 - position))
  }

  fun setMinScale(minScale: Float) {
    if (minScale >= 0.0f && minScale <= 1.0f) {
      mMinScale = minScale
    }
  }
}